package object;

import gameBasics.GameModel;
import gameBasics.GameObject;
import gameBasics.ResourceManager;

import java.awt.*;

public class Wall extends GameObject {

    public final int WIDTH = ResourceManager.wall.getWidth();       //墙的宽度
    public final int HEIGHT = ResourceManager.wall.getHeight();     //墙的高度
    private boolean livingState = true;                             //墙存活状态

    public Wall(int x, int y){
        this.x = x;
        this.y = y;

        rectangle.x = this.x;
        rectangle.y = this.y;
        rectangle.width = this.WIDTH;
        rectangle.height = this.HEIGHT;

        GameModel.getInstance().addGameObject(this);
    }

    /**
     * 绘制墙
     * @param graphics 画笔对象
     */
    @Override
    public void paint(Graphics graphics) {
        if(!livingState) GameModel.getInstance().removeGameObject(this);

        graphics.drawImage(ResourceManager.wall,x,y,null);
    }

    @Override
    public int getWidth() {
        return WIDTH;
    }

    @Override
    public int getHeight() {
        return HEIGHT;
    }

    /**
     * 墙消亡
     */
    public void die() {
        this.livingState = false;
    }

}
